<?  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
class Serviceuser{
     
    
    function data($id){
        $CI =& get_instance();
        $em=$CI->doctrine->em; 
                 
        $query = $em->createQuery(
        'SELECT 
        u.usuario as usuario,
        u.estado as estado,
        u.iduser as id  
        FROM Entity\User u, Entity\Perfil pf, Entity\Persona p, Entity\Distrito d, Entity\Nacionalidad n
        WHERE u.iduser= :id and eliminado=0')
        ->setParameter('id', $id);
 
        $array = $query->getArrayResult();
        return $array;
    }
     
    function login($usuario,$password){
        $CI =& get_instance();
        $em=$CI->doctrine->em;
                 
        $query = $em->createQuery(
        "SELECT 
        u.iduser as iduser,
        u.usuario as usuario
        FROM Entity\User u 
        WHERE u.usuario= :usuario and u.password= :password and u.eliminado=0 and u.estado=1")
        ->setParameter('usuario', $usuario)
        ->setParameter('password', md5($password));
 
        $array = $query->getArrayResult();
        return $array;
        }
     
    function verificaPass($id,$password){
        $CI =& get_instance();
        $em=$CI->doctrine->em;
                 
        $query = $em->createQuery(
        "SELECT 
        u.iduser as iduser,
        u.usuario as usuario
        FROM Entity\User u 
        WHERE u.iduser= :id and u.eliminado=0 and u.estado=1")
        ->setParameter('id', $id)
        ->setParameter('password', md5($password));
 
        $array = $query->getArrayResult();
        if(count($array)>0)
        return true; else return false;
        }
     
     
}
?>